//
//  SSDBManager.swift
//  weibo
//
//  Created by 邵帅 on 16/7/5.
//  Copyright © 2016年 groupNineObject. All rights reserved.
//

import Foundation

import FMDB

class SSDBManager {
    
    static let shareInstance: SSDBManager = SSDBManager()
    
    let queue: FMDatabaseQueue
    
    private init() {
        
        let path = (NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last! as NSString).stringByAppendingPathComponent("weibo.db")
        
        queue = FMDatabaseQueue(path: path)
        
        creatTable()
    }
    
    private func creatTable(){
        
        let sql = "CREATE TABLE IF NOT EXISTS 'T_Status' (" +
            "'status' text," +
            "'statusId' integer NOT NULL," +
            "'userId' integer," +
            "PRIMARY KEY('statusId')" +
        ");"
        
        queue.inDatabase { (db) in
            
            if db.executeStatements(sql){
                
                printLog("创建表格成功")
            }
            
        }
        
    }
    
}